$(function () {
  var username = $(".username input");
  var password = $(".password input");
  var btn = $(".button");
  //66 6 74651
  btn.on("click", function () {
    username = username.val();
    password = password.val();
    console.log(username, password);
    var loginAPI = "http://jx.xuzhixiang.top/ap/api/login.php";
    axios
      .get(loginAPI, { params: { username, password } })
      .then(function (res) {
        console.log(res);
        if (res.data.code == 1) {
          alert("登录成功");
          localStorage.setItem("token", res.data.data.token);
          localStorage.setItem("id", res.data.data.id);
          localStorage.setItem("username", res.data.data.username);
          setInterval(function () {
            location.href = `index.html?uname=${username}`;
          }, 2000);
        } else {
          alert("账号或者密码错误");
        }
      })
      .catch(function (err) {
        // alert("账号或者密码错误");
      });
  });
})();
